<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@taglib prefix="mvc" uri="http://www.springframework.org/tags/form" %>
<%@taglib prefix="fmt" uri="http://www.springframework.org/tags" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <title>申报审核</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=10,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
    <link rel="stylesheet" type="text/css" href="/lib/layui/layui/css/layui.css"/>
    <script type="text/javascript" src="/lib/layui/layui/layui.js"></script>
    <script type="text/javascript" src="/lib/layui/layui/layui.all.js"></script>
    <script type="text/javascript" src="/js/news/jquery-1.9.1.js"></script>
    <script type="text/javascript" src="/lib/jquery-2.1.4.min.js"></script>
    <script src="/js/base/base.js" type="text/javascript" charset="utf-8"></script>
    <script src="../js/sys/citys.js" type="text/javascript" charset="utf-8"></script>

</head>
<style>
    .mbox {
        padding: 8px;
        background: #fff;
    }

    .btn {
        height: 30px;
    }

    .btn button {
        float: right;
    }

    .red_12_normal {
        color: red;
    }

    .form {
        font-size: 9pt;
    }

    .form tr {
        height: 60px;
        line-height: 60px;
    }

    .form th {
        position: relative;
        padding-left: 10px;
        text-align: left;
        white-space: nowrap;
        font-weight: normal;
        width: 90px;
        padding-right: 1px;
    }

    .choice, .empty {
        margin-left: 5px;
    }

    .empty {
        color: red;
    }

    .choice {
        color: blue;
    }
    /* 防止下拉框的下拉列表被隐藏---必须设置--- */
    /*.layui-table-cell {            overflow: visible !important;        }*/
    .layui-table-cell {
        height:auto;
    }
    #tem1 td[data-field="trOther"] .layui-table-cell,
    #tem2 td[data-field="trOther"] .layui-table-cell,
    #tem3 td[data-field="trOther"] .layui-table-cell,
    #tem4 td[data-field="trOther"] .layui-table-cell,
    #tem5 td[data-field="trOther"] .layui-table-cell{
        overflow: visible !important;
    }
    #tem1 td[data-field="type"] .layui-table-cell,
    #tem2 td[data-field="type"] .layui-table-cell,
    #tem3 td[data-field="type"] .layui-table-cell,
    #tem4 td[data-field="type"] .layui-table-cell,
    #tem5 td[data-field="type"] .layui-table-cell{
        overflow: visible !important;
    }
    #tem4 td[data-field="trOther2"] .layui-table-cell,
    #tem5 td[data-field="trOther2"] .layui-table-cell,
    #tem4 td[data-field="trOther3"] .layui-table-cell,
    #tem4 td[data-field="trOther9"] .layui-table-cell,
    #tem4 td[data-field="trOther10"] .layui-table-cell,
    #tem4 td[data-field="trOther11"] .layui-table-cell,
    #tem5 td[data-field="trOther3"] .layui-table-cell,
    #tem5 td[data-field="trOther7"] .layui-table-cell,
    #tem5 td[data-field="trOther9"] .layui-table-cell,
    #tem5 td[data-field="trOther10"] .layui-table-cell{
        overflow: visible !important;
    }
    /* 使得下拉框与单元格刚好合适 */
    td .layui-form-select{
        margin-top: -10px;
        margin-left: -15px;
        margin-right: -15px;
    }
    #form_basic td .layui-form-select{
        margin: 0
    }
    #budgetForm td .layui-form-select{
        margin: 0
    }
    /*解决下拉框被表格覆盖样式问题*/
    .layui-form-select dl {
        z-index: 9999;
    }
    .layui-table-box {
        overflow: visible
    }
    .layui-table-body{
        overflow:visible;
    }
    #tableBox .layui-table-cell .layui-form-checkbox[lay-skin=primary] {
        top: 5px!important;
    }
    #tableBox .layui-table-cell .layui-form-select {
        top: 5px!important;
    }
    /*表格内附件的查阅下载样式*/
    td[data-field="attachmentName"] .layui-table-cell{
        overflow: visible !important;
    }
    .operationDiv{
        position: absolute;
        width: auto;
        border: #ccc 1px solid;
        border-radius: 4px;
        background-color: #ffffff;
        z-index: 99;
    }
    .operationDiv span{
        cursor: pointer;
        display: block;
        height: 30px;
        padding: 5px 0;
        line-height: 20px;
        font-size: 16px;
        text-align: center;
    }
    .operationDiv span:hover{
        background-color: green;
        color: #fff;
    }
</style>
<body>
<div class="mbox">
    <div class="btn">
        <button type="button" id="save" class="layui-btn layui-btn-sm layui-btn-danger" style="display:none;margin-left: 10px;">保存</button>
        <%--<button type="button" class="layui-btn layui-btn-sm layui-btn-warm reset" style="margin-left: 10px;">重置</button>--%>
        <button type="button" class="layui-btn layui-btn-sm comeback">返回
        </button>
    </div>
    <div class="layui-tab layui-tab-card"  lay-filter="tabGolle">
        <ul class="layui-tab-title" id="ulBox">
            <li num="1" class="layui-this">基本信息</li>
            <li num="2">学术著作</li>
            <li num="3">学术论文</li>
            <li num="4">学术论坛主题发言</li>
            <li num="5">结题成果</li>
            <li num="6">评选获奖</li>
        </ul>
        <div class="layui-tab-content" id="tableBox">
            <div class="layui-tab-item layui-show">
                <form class="layui-form" id="form_basic" action="/rpmTopic/insetCertificate">
                    <div class="layui-form-item">
                        <label class="layui-form-label">科室:</label>
                        <div class="layui-input-block">
                            <input type="text" disabled id="deptName" name="deptName" lay-verify="title" autocomplete="off" placeholder="" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">姓名:</label>
                        <div class="layui-input-block">
                            <input type="text" disabled id="userName" name="userName" lay-verify="title" autocomplete="off" placeholder="" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">备案时间:</label>
                        <div class="layui-input-block">
                            <input type="text" disabled name="filingTime" id="filingTime" lay-verify="title" autocomplete="off" placeholder="" class="layui-input">
                        </div>
                    </div>
                </form>
            </div>
            <div class="layui-tab-item" id="tem1">
                <table class="layui-hide" id="participator" lay-filter="participator"></table>
            </div>
            <div class="layui-tab-item" id="tem2">
                <table class="layui-hide" id="academic" lay-filter="academic"></table>
            </div>
            <div class="layui-tab-item" id="tem3">
                <table class="layui-hide" id="achievement" lay-filter="achievement"></table>
            </div>
            <div class="layui-tab-item" id="tem4">
                <table class="layui-hide" id="task" lay-filter="task"></table>
            </div>
            <div class="layui-tab-item" id="tem5">
                <table class="layui-hide" id="expect" lay-filter="expect"></table>
            </div>
        </div>
    </div>
</div>
</body>
</html>
<script type="text/html" id="xuhao">
    {{d.LAY_TABLE_INDEX+1}}
</script>
<script>
    var taskTable;
    var participatorTable;
    var achievementTable;
    var academicTable;
    var expectTable;
    $('.layui-tab-content').height($(window).height() - 130);
    layui.use(['table', 'form', 'laydate', 'upload','element'], function () {
        var table = layui.table,
            form = layui.form,
            laydate = layui.laydate,
            upload = layui.upload,
            element = layui.element;

        //年范围
        laydate.render({
            elem: '#date'
        });
        laydate.render({
            elem: '#startingEndingTime'
        });
        laydate.render({
            elem: '#completionTime'
        });
        // 获取地址栏参数值
        function getQueryString(name){
            var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
            var r = window.location.search.substr(1).match(reg);
            if(r!=null)return  unescape(r[2]); return null;
        }
        var trId = getQueryString("trId");
        var type = getQueryString("btype");
        $('.comeback').click(function(){
            if(getQueryString('type') ==1){
                window.location.href='/Results/resultsManagement'
            }else if(getQueryString('type') ==2){
                window.location.href='/Results/approvedlist'
            }else if(getQueryString('type') ==3){
                window.location.href='/Results/achievementIdentification'
            }else{
                window.location.href='/Results/resultsReview'
            }
        })
        var academicLevelSel,conclusionLevelSel,keynoteAddressLevelSel,selectionLevelSel,thesisLevelSel,conclusionLevelPriv;
        form.render()

        $.ajax({
            url: '/rpmTopic/getDictionary',
            type: 'get',
            dataType: 'json',
            async:false,
            success: function (res) {
                academicLevelSel=res.object.academicLevel
                conclusionLevelSel=res.object.conclusionLevel
                keynoteAddressLevelSel=res.object.keynoteAddressLevel
                selectionLevelSel=res.object.selectionLevel
                thesisLevelSel=res.object.thesisLevel
                conclusionLevelPriv=res.object.conclusionLevelPriv
            }
        })
        $.ajax({
            url: '/rpmTopic/selectgetTopicId',
            data:{
                planId: getQueryString('planId'),
                userId: getQueryString('userId')
            },
            type: 'post',
            dataType: 'json',
            success: function (res) {
                if (res.flag) {
                    var rpmTopic = res.object.rpmTopic
                    var topicId = res.object.rpmTopic.topicId
                    var participator = res.object.rpmTopicRemarkWithBLOBs
                    var achievement = res.object.rpmTopicRemarkWithBLOBs1
                    var academic = res.object.rpmTopicRemarkWithBLOBs2
                    var task = res.object.rpmTopicRemarkWithBLOBs3
                    var expect = res.object.rpmTopicRemarkWithBLOBs4

                    tableData(participator, achievement,academic,task, expect)
                    //基本信息
                    $("#deptName").val(res.object.rpmTopic.deptName);
                    $("#userName").val(res.object.rpmTopic.userName);
                    $("#filingTime").val(res.object.rpmTopic.filingTime);
                    form.render()
                    // var fileStr = '';
                    // if (rpmTopic.attachmentList != undefined && rpmTopic.attachmentList != '') {
                    //     for (var i = 0; i < rpmTopic.attachmentList.length; i++) {
                    //         fileStr += '<div url='+rpmTopic.attachmentList[i].attUrl+' style="display:inline-block; margin-right:25px; " class="fileDiv"><div class="relative">' +
                    //             '   <i class="layui-icon layui-icon-close close"  style="float: right;"></i>' +
                    //             '  <i class="layui-icon layui-icon-list file" id="file"  attachId="' + rpmTopic.attachmentList[i].attachId + '"  deurl="' +encodeURI(rpmTopic.attachmentList[i].attUrl ) + '" ym="'+rpmTopic.attachmentList[i].ym+'" aid="'+rpmTopic.attachmentList[i].aid+'" name="' + rpmTopic.attachmentList[i].attachName + '"  style="font-size: 30px;font-size: 100px; padding-left: 20px;line-height: 140px;"></i>' +
                    //             '  </div>' +
                    //             '  <div style="margin:10px;" class="fileName">' + rpmTopic.attachmentList[i].attachName + '(' + rpmTopic.attachmentList[i].size + ')' + '</div></div>';
                    //     }
                    // }
                    // $('.content').last().append(fileStr);

                } else {
                    var arr = [];
                    tableData(arr,arr,arr,arr,arr)
                }


            }
        })
        function tableData(participator,academic,achievement,task, expect) {
            // 学术著作
            participatorTable =  table.render({
                elem: '#participator'
                , data:participator
                , title: '学术著作'
                , cols: [[
                    {field: 'topicId', hide: true}
                    ,{field: 'numbers', title: '序号',templet: '#xuhao',width:60}
                    , {field: 'trOther', title: '级别',templet:function () {
                            var str='<option>请选择</option>'
                            for(var i=0;i<academicLevelSel.length;i++){
                                str+='<option value="'+academicLevelSel[i].dictNo+'">'+academicLevelSel[i].dictName+'</option>'
                            }
                            return ' <select name="trOther" lay-filter="trOther" >'+str+'</select>'
                        }}
                    , {field: 'trOther2', title: '成果名称'}
                    , {field: 'trOther3', title: '出版单位'}
                    , {
                        field: 'trTime',
                        title: '出版时间',
                        event: 'trTime',
                        data_field: "trTime"
                    }
                    , {field: 'trOther4', title: '备注'}
                    , {
                        field: 'attachmentName',  width:270,title: '附件',event:'viewReport',
                        templet:
                            function (d) {
                                var attachmentIds = d.attachmentId;
                                var attachmentNames = d.attachmentName;
                                if (attachmentNames != undefined && attachmentNames.length > 0) {
                                    var attachIdArray = "";
                                    if (attachmentIds != undefined) {
                                        attachIdArray = attachmentIds.split(",")
                                    }
                                    var attachNameArray = attachmentNames.split(",")
                                    var $as = "";
                                    for (var i = 0; i < attachNameArray.length; i++) {
                                        var attachId = "";
                                        if (i < attachIdArray.length) {
                                            attachId = attachIdArray[i];
                                        }
                                        var attachName = attachNameArray[i];
                                        var c = "";
                                        if (i > 0) {
                                            c = ",";
                                        }
                                        if (attachName != "") {
                                            $as += '<div onmouseenter="shover($(this))" onmouseleave="sover($(this))"><span style="color:green;cursor: pointer;width: 100%;display: inline-block;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;" attachName="' + attachName + '" attachId="' + attachId + '"  class="layui-table-link aUploadFile giv">' + "【" + attachName + "】" + '</span><div class="operationDiv" style="display: none;"><span href="javascript:;" class="spanNa" style="cursor: pointer;"></span><span class="" attachName="\' + attachName + \'" attachId="\' + attachId + \'" onclick="look($(this))" href="javascript:;">查阅</span><span class="" attachName="\' + attachName + \'" attachId="\' + attachId + \'" onclick="down($(this))" >下载</span></div></div><br style="line-height: 1px;"/>'
                                        }

                                    }
                                    return '<div id="tdBox">' + $as + '</div>'
                                } else {
                                    return '<div><span style="color:green" class="layui-table-link aUploadFile">' + "" + '</span></div>'
                                }
                            }
                    }
                    , {field: 'type', title: '评审',templet:function () {
                            var str='<option value="0">请选择</option>'
                            str+='<option value="通过">通过</option>'
                            str+='<option value="未通过">未通过</option>'
                            return ' <select name="trOther8" lay-filter="trOther8" >'+str+'</select>'
                        }}
                ]]
                , page: true
                , done: function (obj) {
                    if(type == "look"){
                        $("select").attr("disabled","disabled");
                    }else if(type == "edit"){
                        $("select").attr("disabled","disabled");
                        $('select[name="trOther8"]').removeAttr("disabled");
                    }
                    form.on('select(trOther)', function(pr){
                        var dataindex=$(pr.elem).parents('tr').attr("data-index");
                        data[dataindex].trOther=pr.value;
                    });
                    var data=obj.data;
                    var selectId = $(this.elem[0].nextElementSibling)
                        , mineSelparentTyepNo = $(selectId).find("select[name='trOther']")
                    for (var i = 0; i < obj.data.length; i++) {
                        layui.each(mineSelparentTyepNo, function (index, item) {
                            if (index == i) $(item).find('option[value="' + obj.data[i].trOther + '"]').prop('selected', 'selected');
                            // $(item).attr('disabled', 'disabled').attr('dataType', '1')
                        });
                    }
                    form.on('select(trOther8)', function(pr){
                        var dataindex=$(pr.elem).parents('tr').attr("data-index");
                        data[dataindex].trOther8=pr.value;
                    });
                    var selectId = $(this.elem[0].nextElementSibling)
                        , mineSelparentTyepNo = $(selectId).find("select[name='trOther8']")
                    for (var i = 0; i < obj.data.length; i++) {
                        layui.each(mineSelparentTyepNo, function (index, item) {
                            if (index == i) $(item).find('option[value="' + obj.data[i].trOther8 + '"]').prop('selected', 'selected');
                            // $(item).attr('disabled', 'disabled').attr('dataType', '1')
                        });
                    }
                    form.render()
                }
            });
            // 学术论文
            academicTable = table.render({
                elem: '#academic'
                , data:academic
                , title: '学术论文'
                , cols: [[
                    {field: 'topicId', hide: true}
                    , {field: 'numbers', title: '序号',templet: '#xuhao',width:60}
                    , {field: 'trOther', title: '级别',templet:function () {
                            var str='<option>请选择</option>'
                            for(var i=0;i<thesisLevelSel.length;i++){
                                str+='<option value="'+thesisLevelSel[i].dictNo+'">'+thesisLevelSel[i].dictName+'</option>'
                            }
                            return ' <select name="trOther" lay-filter="trOther" >'+str+'</select>'
                        }}
                    , {field: 'trOther2', title: '成果名称'}
                    , {field: 'trOther3', title: '发表刊物'}
                    , {
                        field: 'trTime',
                        title: '发表时间',
                        event: 'trTime',
                        data_field: "trTime"
                    }
                    , {field: 'trOther4', title: '备注'}
                    , {
                        field: 'attachmentName',  width:270,title: '附件',event:'viewReport',
                        templet:
                            function (d) {
                                var attachmentIds = d.attachmentId;
                                var attachmentNames = d.attachmentName;
                                if (attachmentNames != undefined && attachmentNames.length > 0) {
                                    var attachIdArray = "";
                                    if (attachmentIds != undefined) {
                                        attachIdArray = attachmentIds.split(",")
                                    }
                                    var attachNameArray = attachmentNames.split(",")
                                    var $as = "";
                                    for (var i = 0; i < attachNameArray.length; i++) {
                                        var attachId = "";
                                        if (i < attachIdArray.length) {
                                            attachId = attachIdArray[i];
                                        }
                                        var attachName = attachNameArray[i];
                                        var c = "";
                                        if (i > 0) {
                                            c = ",";
                                        }
                                        if (attachName != "") {
                                            $as += '<div onmouseenter="shover($(this))" onmouseleave="sover($(this))"><span style="color:green;cursor: pointer;width: 100%;display: inline-block;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;" attachName="' + attachName + '" attachId="' + attachId + '"  class="layui-table-link aUploadFile giv">' + "【" + attachName + "】" + '</span><div class="operationDiv" style="display: none;"><span href="javascript:;" class="spanNa" style="cursor: pointer;"></span><span class="" attachName="\' + attachName + \'" attachId="\' + attachId + \'" onclick="look($(this))" href="javascript:;">查阅</span><span class="" attachName="\' + attachName + \'" attachId="\' + attachId + \'" onclick="down($(this))" >下载</span></div></div><br style="line-height: 1px;"/>'
                                        }

                                    }
                                    return '<div id="tdBox">' + $as + '</div>'
                                } else {
                                    return '<div><span style="color:green" class="layui-table-link aUploadFile">' + "" + '</span></div>'
                                }
                            }
                    }
                    , {field: 'type', title: '评审',templet:function () {
                            var str='<option value="0">请选择</option>'
                            str+='<option value="通过">通过</option>'
                            str+='<option value="未通过">未通过</option>'
                            return ' <select name="trOther8" lay-filter="trOther8" >'+str+'</select>'
                        }}
                ]]
                , page: true
                , done: function (obj) {
                    if(type == "look"){
                        $("select").attr("disabled","disabled");
                    }else if(type == "edit"){
                        $("select").attr("disabled","disabled");
                        $('select[name="trOther8"]').removeAttr("disabled");
                    }
                    var data=obj.data;
                    form.on('select(trOther)', function(pr){
                        var dataindex=$(pr.elem).parents('tr').attr("data-index");
                        data[dataindex].trOther=pr.value;
                    });

                    var selectId = $(this.elem[0].nextElementSibling)
                        , mineSelparentTyepNo = $(selectId).find("select[name='trOther']")
                    for (var i = 0; i < obj.data.length; i++) {
                        layui.each(mineSelparentTyepNo, function (index, item) {
                            if (index == i) $(item).find('option[value="' + obj.data[i].trOther + '"]').prop('selected', 'selected');
                            // $(item).attr('disabled', 'disabled').attr('dataType', '1')
                        });
                    }
                    form.on('select(trOther8)', function(pr){
                        var dataindex=$(pr.elem).parents('tr').attr("data-index");
                        data[dataindex].trOther8=pr.value;
                    });
                    var selectId = $(this.elem[0].nextElementSibling)
                        , mineSelparentTyepNo = $(selectId).find("select[name='trOther8']")
                    for (var i = 0; i < obj.data.length; i++) {
                        layui.each(mineSelparentTyepNo, function (index, item) {
                            if (index == i) $(item).find('option[value="' + obj.data[i].trOther8 + '"]').prop('selected', 'selected');
                            // $(item).attr('disabled', 'disabled').attr('dataType', '1')
                        });
                    }
                    form.render()
                }
            });
            // 学术论坛主题发言
            achievementTable = table.render({
                elem: '#achievement'
                , data:achievement
                , title: '学术论坛主题发言'
                , page: true
                , cols: [[
                    {field: 'topicId', hide: true}
                    ,{field: 'numbers', title: '序号',templet: '#xuhao',width:70}
                    , {field: 'trOther', title: '级别',templet:function () {
                            var str='<option>请选择</option>'
                            for(var i=0;i<keynoteAddressLevelSel.length;i++){
                                str+='<option value="'+keynoteAddressLevelSel[i].dictNo+'">'+keynoteAddressLevelSel[i].dictName+'</option>'
                            }
                            return ' <select name="trOther" lay-filter="trOther" >'+str+'</select>'
                        }}
                    , {field: 'trOther2', title: '成果名称'}
                    , {field: 'trOther3', title: '学术论坛名称'}
                    , {
                        field: 'trTime',
                        title: '交流时间',
                        event: 'trTime',
                        data_field: "trTime"
                    }
                    , {field: 'trOther4', title: '备注'}
                    , {
                        field: 'attachmentName',  width:270,title: '附件',event:'viewReport',
                        templet:
                            function (d) {
                                var attachmentIds = d.attachmentId;
                                var attachmentNames = d.attachmentName;
                                if (attachmentNames != undefined && attachmentNames.length > 0) {
                                    var attachIdArray = "";
                                    if (attachmentIds != undefined) {
                                        attachIdArray = attachmentIds.split(",")
                                    }
                                    var attachNameArray = attachmentNames.split(",")
                                    var $as = "";
                                    for (var i = 0; i < attachNameArray.length; i++) {
                                        var attachId = "";
                                        if (i < attachIdArray.length) {
                                            attachId = attachIdArray[i];
                                        }
                                        var attachName = attachNameArray[i];
                                        var c = "";
                                        if (i > 0) {
                                            c = ",";
                                        }
                                        if (attachName != "") {
                                            $as += '<div onmouseenter="shover($(this))" onmouseleave="sover($(this))"><span style="color:green;cursor: pointer;width: 100%;display: inline-block;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;" attachName="' + attachName + '" attachId="' + attachId + '"  class="layui-table-link aUploadFile giv">' + "【" + attachName + "】" + '</span><div class="operationDiv" style="display: none;"><span href="javascript:;" class="spanNa" style="cursor: pointer;"></span><span class="" attachName="\' + attachName + \'" attachId="\' + attachId + \'" onclick="look($(this))" href="javascript:;">查阅</span><span class="" attachName="\' + attachName + \'" attachId="\' + attachId + \'" onclick="down($(this))" >下载</span></div></div><br style="line-height: 1px;"/>'
                                        }

                                    }
                                    return '<div id="tdBox">' + $as + '</div>'
                                } else {
                                    return '<div><span style="color:green" class="layui-table-link aUploadFile">' + "" + '</span></div>'
                                }
                            }
                    }
                    , {field: 'type', title: '评审',templet:function () {
                            var str='<option value="0">请选择</option>'
                            str+='<option value="通过">通过</option>'
                            str+='<option value="未通过">未通过</option>'
                            return ' <select name="trOther8" lay-filter="trOther8" >'+str+'</select>'
                        }}
                ]]
                ,done:function(obj){
                    if(type == "look"){
                        $("select").attr("disabled","disabled");
                    }else if(type == "edit"){
                        $("select").attr("disabled","disabled");
                        $('select[name="trOther8"]').removeAttr("disabled");
                    }
                    var data=obj.data;
                    form.on('select(trOther)', function(pr){
                        var dataindex=$(pr.elem).parents('tr').attr("data-index");
                        data[dataindex].trOther=pr.value;
                    });
                    var selectId = $(this.elem[0].nextElementSibling)
                        , mineSelparentTyepNo = $(selectId).find("select[name='trOther']")
                    for (var i = 0; i < obj.data.length; i++) {
                        layui.each(mineSelparentTyepNo, function (index, item) {
                            if (index == i) $(item).find('option[value="'+ obj.data[i].trOther + '"]').prop('selected', 'selected');
                            // $(item).attr('disabled', 'disabled').attr('dataType', '1')
                        });
                    }
                    form.on('select(trOther8)', function(pr){
                        var dataindex=$(pr.elem).parents('tr').attr("data-index");
                        data[dataindex].trOther8=pr.value;
                    });
                    var selectId = $(this.elem[0].nextElementSibling)
                        , mineSelparentTyepNo = $(selectId).find("select[name='trOther8']")
                    for (var i = 0; i < obj.data.length; i++) {
                        layui.each(mineSelparentTyepNo, function (index, item) {
                            if (index == i) $(item).find('option[value="' + obj.data[i].trOther8 + '"]').prop('selected', 'selected');
                            // $(item).attr('disabled', 'disabled').attr('dataType', '1')
                        });
                    }
                    form.render()
                }
            });
            // 结题成果
            taskTable = table.render({
                elem: '#task'
                , data: task
                , title: '结题成果'
                , cols: [[
                    {field: 'topicId', hide: true}
                    , {field: 'numbers', title: '序号',templet: '#xuhao',width:70}
                    , {field: 'trOther4', title: '角色'}
                    , {field: 'trOther5', title: '课题名称'}
                    , {field: 'trOther6', title: '批准单位'}
                    , {field: 'trOther', title: '部级及以上',width:90,templet:function () {
                            var str='<option>请选择</option>'
                            for(var i=0;i<conclusionLevelSel.length;i++){
                                str+='<option value="'+conclusionLevelSel[i].dictNo+'">'+conclusionLevelSel[i].dictName+'</option>'
                            }
                            return ' <select name="trOther" lay-filter="trOther" >'+str+'</select>'
                        }}
                    , {field: 'trOther11', title: '部级评审',templet:function () {
                            var str='<option value="0">请选择</option>'
                            str+='<option value="通过">通过</option>'
                            str+='<option value="未通过">未通过</option>'
                            return ' <select name="trOther11" lay-filter="trOther11" >'+str+'</select>'
                        }}
                    , {field: 'trOther2', title: '市区重点',templet:function () {
                            var str='<option>请选择</option>'
                            for(var i=0;i<conclusionLevelSel.length;i++){
                                str+='<option value="'+conclusionLevelSel[i].dictNo+'">'+conclusionLevelSel[i].dictName+'</option>'
                            }
                            return ' <select name="trOther2" lay-filter="trOther2" >'+str+'</select>'
                        }}
                    , {field: 'trOther9', title: '市区评审',templet:function () {
                            var str='<option value="0">请选择</option>'
                            str+='<option value="通过">通过</option>'
                            str+='<option value="未通过">未通过</option>'
                            return ' <select name="trOther9" lay-filter="trOther9" >'+str+'</select>'
                        }}
                    , {field: 'trOther3', title: '区级其他',templet:function () {
                            var str='<option>请选择</option>'
                            for(var i=0;i<conclusionLevelSel.length;i++){
                                str+='<option value="'+conclusionLevelSel[i].dictNo+'">'+conclusionLevelSel[i].dictName+'</option>'
                            }
                            return ' <select name="trOther3" lay-filter="trOther3" >'+str+'</select>'
                        }}
                    , {field: 'trOther10', title: '区级评审',templet:function () {
                            var str='<option value="0">请选择</option>'
                            str+='<option value="通过">通过</option>'
                            str+='<option value="未通过">未通过</option>'
                            return ' <select name="trOther10" lay-filter="trOther10" >'+str+'</select>'
                        }}
                    , {field: 'trOther7', title: '备注'}
                    , {
                        field: 'attachmentName',  width:270,title: '附件',event:'viewReport',
                        templet:
                            function (d) {
                                var attachmentIds = d.attachmentId;
                                var attachmentNames = d.attachmentName;
                                if (attachmentNames != undefined && attachmentNames.length > 0) {
                                    var attachIdArray = "";
                                    if (attachmentIds != undefined) {
                                        attachIdArray = attachmentIds.split(",")
                                    }
                                    var attachNameArray = attachmentNames.split(",")
                                    var $as = "";
                                    for (var i = 0; i < attachNameArray.length; i++) {
                                        var attachId = "";
                                        if (i < attachIdArray.length) {
                                            attachId = attachIdArray[i];
                                        }
                                        var attachName = attachNameArray[i];
                                        var c = "";
                                        if (i > 0) {
                                            c = ",";
                                        }
                                        if (attachName != "") {
                                            $as += '<div onmouseenter="shover($(this))" onmouseleave="sover($(this))"><span style="color:green;cursor: pointer;width: 100%;display: inline-block;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;" attachName="' + attachName + '" attachId="' + attachId + '"  class="layui-table-link aUploadFile giv">' + "【" + attachName + "】" + '</span><div class="operationDiv" style="display: none;"><span href="javascript:;" class="spanNa" style="cursor: pointer;"></span><span class="" attachName="\' + attachName + \'" attachId="\' + attachId + \'" onclick="look($(this))" href="javascript:;">查阅</span><span class="" attachName="\' + attachName + \'" attachId="\' + attachId + \'" onclick="down($(this))" >下载</span></div></div><br style="line-height: 1px;"/>'
                                        }

                                    }
                                    return '<div id="tdBox">' + $as + '</div>'
                                } else {
                                    return '<div><span style="color:green" class="layui-table-link aUploadFile">' + "" + '</span></div>'
                                }
                            }
                    }
                    , {field: 'type', title: '评审',templet:function () {
                            var str='<option value="0">请选择</option>'
                            str+='<option value="通过">通过</option>'
                            str+='<option value="未通过">未通过</option>'
                            return ' <select name="trOther8" lay-filter="trOther8" >'+str+'</select>'
                        }}
                ]]
                , page: true
                ,done:function (obj) {
                    if(type == "look"){
                        $("select").attr("disabled","disabled");
                    }else if(type == "edit"){
                        $("select").attr("disabled","disabled");
                        $('select[name="trOther8"]').removeAttr("disabled");
                        $('select[name="trOther9"]').removeAttr("disabled");
                        $('select[name="trOther10"]').removeAttr("disabled");
                        $('select[name="trOther11"]').removeAttr("disabled");
                    }
                    var data=obj.data;
                    form.on('select(trOther)', function(pr){
                        var dataindex=$(pr.elem).parents('tr').attr("data-index");
                        data[dataindex].trOther=pr.value;
                    });
                    var selectId = $(this.elem[0].nextElementSibling)
                        , mineSelparentTyepNo = $(selectId).find("select[name='trOther']")
                    for (var i = 0; i < obj.data.length; i++) {
                        layui.each(mineSelparentTyepNo, function (index, item) {
                            if (index == i) $(item).find('option[value="' + obj.data[i].trOther + '"]').prop('selected', 'selected');
                            // $(item).attr('disabled', 'disabled').attr('dataType', '1')
                        });
                    }
                    form.on('select(trOther2)', function(pr){
                        var dataindex=$(pr.elem).parents('tr').attr("data-index");
                        data[dataindex].trOther2=pr.value;
                    });
                    var selectId = $(this.elem[0].nextElementSibling)
                        , mineSelparentTyepNo = $(selectId).find("select[name='trOther2']")
                    for (var i = 0; i < obj.data.length; i++) {
                        layui.each(mineSelparentTyepNo, function (index, item) {
                            if (index == i) $(item).find('option[value="' + obj.data[i].trOther2 + '"]').prop('selected', 'selected');
                            // $(item).attr('disabled', 'disabled').attr('dataType', '1')
                        });
                    }
                    form.on('select(trOther3)', function(pr){
                        var dataindex=$(pr.elem).parents('tr').attr("data-index");
                        data[dataindex].trOther3=pr.value;
                    });
                    var selectId = $(this.elem[0].nextElementSibling)
                        , mineSelparentTyepNo = $(selectId).find("select[name='trOther3']")
                    for (var i = 0; i < obj.data.length; i++) {
                        layui.each(mineSelparentTyepNo, function (index, item) {
                            if (index == i) $(item).find('option[value="' + obj.data[i].trOther3 + '"]').prop('selected', 'selected');
                            // $(item).attr('disabled', 'disabled').attr('dataType', '1')
                        });
                    }
                    form.on('select(trOther8)', function(pr){
                        var dataindex=$(pr.elem).parents('tr').attr("data-index");
                        data[dataindex].trOther8=pr.value;
                    });
                    var selectId = $(this.elem[0].nextElementSibling)
                        , mineSelparentTyepNo = $(selectId).find("select[name='trOther8']")
                    for (var i = 0; i < obj.data.length; i++) {
                        layui.each(mineSelparentTyepNo, function (index, item) {
                            if (index == i) $(item).find('option[value="' + obj.data[i].trOther8 + '"]').prop('selected', 'selected');
                            // $(item).attr('disabled', 'disabled').attr('dataType', '1')
                        });
                    }
                    form.on('select(trOther9)', function(pr){
                        var dataindex=$(pr.elem).parents('tr').attr("data-index");
                        data[dataindex].trOther9=pr.value;
                    });
                    var selectId = $(this.elem[0].nextElementSibling)
                        , mineSelparentTyepNo = $(selectId).find("select[name='trOther9']")
                    for (var i = 0; i < obj.data.length; i++) {
                        layui.each(mineSelparentTyepNo, function (index, item) {
                            if (index == i) $(item).find('option[value="' + obj.data[i].trOther9 + '"]').prop('selected', 'selected');
                            // $(item).attr('disabled', 'disabled').attr('dataType', '1')
                        });
                    }
                    form.on('select(trOther10)', function(pr){
                        var dataindex=$(pr.elem).parents('tr').attr("data-index");
                        data[dataindex].trOther10=pr.value;
                    });
                    var selectId = $(this.elem[0].nextElementSibling)
                        , mineSelparentTyepNo = $(selectId).find("select[name='trOther10']")
                    for (var i = 0; i < obj.data.length; i++) {
                        layui.each(mineSelparentTyepNo, function (index, item) {
                            if (index == i) $(item).find('option[value="' + obj.data[i].trOther10 + '"]').prop('selected', 'selected');
                            // $(item).attr('disabled', 'disabled').attr('dataType', '1')
                        });
                    }
                    form.on('select(trOther11)', function(pr){
                        var dataindex=$(pr.elem).parents('tr').attr("data-index");
                        data[dataindex].trOther11=pr.value;
                    });
                    var selectId = $(this.elem[0].nextElementSibling)
                        , mineSelparentTyepNo = $(selectId).find("select[name='trOther11']")
                    for (var i = 0; i < obj.data.length; i++) {
                        layui.each(mineSelparentTyepNo, function (index, item) {
                            if (index == i) $(item).find('option[value="' + obj.data[i].trOther11 + '"]').prop('selected', 'selected');
                            // $(item).attr('disabled', 'disabled').attr('dataType', '1')
                        });
                    }
                    form.render()
                }
            });
            // 评选获奖
            expectTable = table.render({
                elem: '#expect'
                , data: expect
                , title: '评选获奖'
                , cols: [[
                    {field: 'topicId', hide: true}
                    , {field: 'numbers', title: '序号',templet: '#xuhao',width:70}
                    , {field: 'trOther', title: '部级及以上',width:90,templet:function () {
                            var str='<option>请选择</option>'
                            for(var i=0;i<selectionLevelSel.length;i++){
                                str+='<option value="'+selectionLevelSel[i].dictNo+'">'+selectionLevelSel[i].dictName+'</option>'
                            }
                            return ' <select name="trOther" lay-filter="trOther" >'+str+'</select>'
                        }}
                    , {field: 'trOther7', title: '部级评审',templet:function () {
                            var str='<option value="0">请选择</option>'
                            str+='<option value="通过">通过</option>'
                            str+='<option value="未通过">未通过</option>'
                            return ' <select name="trOther7" lay-filter="trOther7" >'+str+'</select>'
                        }}
                    , {field: 'trOther2', title: '市级(区重点)',width:100,templet:function () {
                            var str='<option>请选择</option>'
                            for(var i=0;i<selectionLevelSel.length;i++){
                                str+='<option value="'+selectionLevelSel[i].dictNo+'">'+selectionLevelSel[i].dictName+'</option>'
                            }
                            return ' <select name="trOther2" lay-filter="trOther2" >'+str+'</select>'
                        }}
                    , {field: 'trOther9', title: '市级评审',templet:function () {
                            var str='<option value="0">请选择</option>'
                            str+='<option value="通过">通过</option>'
                            str+='<option value="未通过">未通过</option>'
                            return ' <select name="trOther9" lay-filter="trOther9" >'+str+'</select>'
                        }}
                    , {
                        field: 'trOther3', title: '区级其他', templet: function (obj) {
                            var str='<option>请选择</option>'
                            for(var i=0;i<selectionLevelSel.length;i++){
                                str+='<option value="'+selectionLevelSel[i].dictNo+'">'+selectionLevelSel[i].dictName+'</option>'
                            }
                            return ' <select name="trOther3" lay-filter="trOther3" >'+str+'</select>'
                        }
                    }
                    , {field: 'trOther10', title: '区级评审',templet:function () {
                            var str='<option value="0">请选择</option>'
                            str+='<option value="通过">通过</option>'
                            str+='<option value="未通过">未通过</option>'
                            return ' <select name="trOther10" lay-filter="trOther10" >'+str+'</select>'
                        }}
                    , {field: 'trOther4', title: '成果名称'}
                    , {field: 'trOther5', title: '成果评审主办单位',width:160}
                    , {field: 'trOther6', title: '备注'}
                    , {
                        field: 'attachmentName',  width:210,title: '附件',event:'viewReport',
                        templet:
                            function (d) {
                                var attachmentIds = d.attachmentId;
                                var attachmentNames = d.attachmentName;
                                if (attachmentNames != undefined && attachmentNames.length > 0) {
                                    var attachIdArray = "";
                                    if (attachmentIds != undefined) {
                                        attachIdArray = attachmentIds.split(",")
                                    }
                                    var attachNameArray = attachmentNames.split(",")
                                    var $as = "";
                                    for (var i = 0; i < attachNameArray.length; i++) {
                                        var attachId = "";
                                        if (i < attachIdArray.length) {
                                            attachId = attachIdArray[i];
                                        }
                                        var attachName = attachNameArray[i];
                                        var c = "";
                                        if (i > 0) {
                                            c = ",";
                                        }
                                        if (attachName != "") {
                                            $as += '<div onmouseenter="shover($(this))" onmouseleave="sover($(this))"><span  style="color:green;cursor: pointer;width: 100%;display: inline-block;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;" attachName="' + attachName + '" attachId="' + attachId + '"  class="layui-table-link aUploadFile giv">' + "【" + attachName + "】" + '</span><div class="operationDiv" style="display: none;"><span href="javascript:;" class="spanNa" style="cursor: pointer;"></span><span class="" attachName="\' + attachName + \'" attachId="\' + attachId + \'" onclick="look($(this))" href="javascript:;">查阅</span><span class="" attachName="\' + attachName + \'" attachId="\' + attachId + \'" onclick="down($(this))" >下载</span></div></div><br style="line-height: 1px;"/>'
                                        }

                                    }
                                    return '<div id="tdBox">' + $as + '</div>'
                                } else {
                                    return '<div><span style="color:green" class="layui-table-link aUploadFile">' + "" + '</span></div>'
                                }
                            }
                    }
                    , {field: 'type', title: '评审',templet:function () {
                            var str='<option value="0">请选择</option>'
                            str+='<option value="通过">通过</option>'
                            str+='<option value="未通过">未通过</option>'
                            return ' <select name="trOther8" lay-filter="trOther8" >'+str+'</select>'
                        }}
                ]]
                , page: true
                , done: function (obj) {
                    if(type == "look"){
                        $("select").attr("disabled","disabled");
                    }else if(type == "edit"){
                        $("select").attr("disabled","disabled");
                        $('select[name="trOther7"]').removeAttr("disabled");
                        $('select[name="trOther8"]').removeAttr("disabled");
                        $('select[name="trOther9"]').removeAttr("disabled");
                        $('select[name="trOther10"]').removeAttr("disabled");
                        $('select[name="trOther11"]').removeAttr("disabled");
                    }
                    var data=obj.data;
                    form.on('select(trOther)', function(pr){
                        var dataindex=$(pr.elem).parents('tr').attr("data-index");
                        data[dataindex].trOther=pr.value;
                    });
                    var selectId = $(this.elem[0].nextElementSibling)
                        , mineSelparentTyepNo = $(selectId).find("select[name='trOther']")
                    for (var i = 0; i < obj.data.length; i++) {
                        layui.each(mineSelparentTyepNo, function (index, item) {
                            if (index == i) $(item).find('option[value="' + obj.data[i].trOther + '"]').prop('selected', 'selected');
                            // $(item).attr('disabled', 'disabled').attr('dataType', '1')
                        });
                    }
                    form.on('select(trOther2)', function(pr){
                        var dataindex=$(pr.elem).parents('tr').attr("data-index");
                        data[dataindex].trOther2=pr.value;
                    });
                    var selectId = $(this.elem[0].nextElementSibling)
                        , mineSelparentTyepNo = $(selectId).find("select[name='trOther2']")
                    for (var i = 0; i < obj.data.length; i++) {
                        layui.each(mineSelparentTyepNo, function (index, item) {
                            if (index == i) $(item).find('option[value="' + obj.data[i].trOther2 + '"]').prop('selected', 'selected');
                            // $(item).attr('disabled', 'disabled').attr('dataType', '1')
                        });
                    }
                    form.on('select(trOther3)', function(pr){
                        var dataindex=$(pr.elem).parents('tr').attr("data-index");
                        data[dataindex].trOther3=pr.value;
                    });
                    var selectId = $(this.elem[0].nextElementSibling)
                        , mineSelparentTyepNo = $(selectId).find("select[name='trOther3']")
                    for (var i = 0; i < obj.data.length; i++) {
                        layui.each(mineSelparentTyepNo, function (index, item) {
                            if (index == i) $(item).find('option[value="' + obj.data[i].trOther3 + '"]').prop('selected', 'selected');
                            // $(item).attr('disabled', 'disabled').attr('dataType', '1')
                        });
                    }
                    form.on('select(trOther7)', function(pr){
                        var dataindex=$(pr.elem).parents('tr').attr("data-index");
                        data[dataindex].trOther7=pr.value;
                    });
                    var selectId = $(this.elem[0].nextElementSibling)
                        , mineSelparentTyepNo = $(selectId).find("select[name='trOther7']")
                    for (var i = 0; i < obj.data.length; i++) {
                        layui.each(mineSelparentTyepNo, function (index, item) {
                            if (index == i) $(item).find('option[value="' + obj.data[i].trOther7 + '"]').prop('selected', 'selected');
                            // $(item).attr('disabled', 'disabled').attr('dataType', '1')
                        });
                    }
                    form.on('select(trOther8)', function(pr){
                        var dataindex=$(pr.elem).parents('tr').attr("data-index");
                        data[dataindex].trOther8=pr.value;
                    });
                    var selectId = $(this.elem[0].nextElementSibling)
                        , mineSelparentTyepNo = $(selectId).find("select[name='trOther8']")
                    for (var i = 0; i < obj.data.length; i++) {
                        layui.each(mineSelparentTyepNo, function (index, item) {
                            if (index == i) $(item).find('option[value="' + obj.data[i].trOther8 + '"]').prop('selected', 'selected');
                            // $(item).attr('disabled', 'disabled').attr('dataType', '1')
                        });
                    }
                    form.on('select(trOther9)', function(pr){
                        var dataindex=$(pr.elem).parents('tr').attr("data-index");
                        data[dataindex].trOther9=pr.value;
                    });
                    var selectId = $(this.elem[0].nextElementSibling)
                        , mineSelparentTyepNo = $(selectId).find("select[name='trOther9']")
                    for (var i = 0; i < obj.data.length; i++) {
                        layui.each(mineSelparentTyepNo, function (index, item) {
                            if (index == i) $(item).find('option[value="' + obj.data[i].trOther9 + '"]').prop('selected', 'selected');
                            // $(item).attr('disabled', 'disabled').attr('dataType', '1')
                        });
                    }
                    form.on('select(trOther10)', function(pr){
                        var dataindex=$(pr.elem).parents('tr').attr("data-index");
                        data[dataindex].trOther10=pr.value;
                    });
                    var selectId = $(this.elem[0].nextElementSibling)
                        , mineSelparentTyepNo = $(selectId).find("select[name='trOther10']")
                    for (var i = 0; i < obj.data.length; i++) {
                        layui.each(mineSelparentTyepNo, function (index, item) {
                            if (index == i) $(item).find('option[value="' + obj.data[i].trOther10 + '"]').prop('selected', 'selected');
                            // $(item).attr('disabled', 'disabled').attr('dataType', '1')
                        });
                    }
                    form.on('select(trOther11)', function(pr){
                        var dataindex=$(pr.elem).parents('tr').attr("data-index");
                        data[dataindex].trOther11=pr.value;
                    });
                    var selectId = $(this.elem[0].nextElementSibling)
                        , mineSelparentTyepNo = $(selectId).find("select[name='trOther11']")
                    for (var i = 0; i < obj.data.length; i++) {
                        layui.each(mineSelparentTyepNo, function (index, item) {
                            if (index == i) $(item).find('option[value="' + obj.data[i].trOther11 + '"]').prop('selected', 'selected');
                            // $(item).attr('disabled', 'disabled').attr('dataType', '1')
                        });
                    }
                    form.render()
                }
            });
        }
        //页签切换监听事件
        element.on('tab(tabGolle)', function(data){
            if(data.index==0){
                $("#save").css("display","none");
            }else if(data.index==1){
                if(type == "look"){
                    $(".btn #save").css("display","none");
                }else{
                    $(".btn #save").css("display","block");
                }
            }else if(data.index==2){
                if(type == "look"){
                    $(".btn #save").css("display","none");
                }else{
                    $(".btn #save").css("display","block");
                }
            }else if(data.index==3){
                if(type == "look"){
                    $(".btn #save").css("display","none");
                }else{
                    $(".btn #save").css("display","block");
                }
            }else if(data.index==4){
                if(type == "look"){
                    $(".btn #save").css("display","none");
                }else{
                    $(".btn #save").css("display","block");
                }
            }else if(data.index==5){
                if(type == "look"){
                    $(".btn #save").css("display","none");
                }else{
                    $(".btn #save").css("display","block");
                }
            }
        });
        $("#save").click(function(){
            var num = $("#ulBox").find("li.layui-this").attr("num");
            if(num == "2"){
                var data = table.cache["participator"];
                var $tr = $("#participator").next(".layui-form").find("tbody tr");
                for(var i=0;i<$tr.length;i++){
                    data[i].trOther8 = $($tr).eq(i).find('td[data-field="type"] dl dd.layui-this').attr("lay-value");
                    if($($tr).eq(i).find('td[data-field="type"] dl dd.layui-this').attr("lay-value") == "通过"){
                        data[i].trStatus = "2";
                    }else if($($tr).eq(i).find('td[data-field="type"] dl dd.layui-this').attr("lay-value") == "未通过"){
                        data[i].trStatus = "3";
                    }
                }
            }
            if(num == "3"){
                var data = table.cache["academic"];
                var $tr = $("#academic").next(".layui-form").find("tbody tr");
                for(var i=0;i<$tr.length;i++){
                    data[i].trOther8 = $($tr).eq(i).find('td[data-field="type"] dl dd.layui-this').attr("lay-value");
                    if($($tr).eq(i).find('td[data-field="type"] dl dd.layui-this').attr("lay-value") == "通过"){
                        data[i].trStatus = "2";
                    }else if($($tr).eq(i).find('td[data-field="type"] dl dd.layui-this').attr("lay-value") == "未通过"){
                        data[i].trStatus = "3";
                    }
                }
            }
            if(num == "4"){
                var data = table.cache["achievement"];
                var $tr = $("#achievement").next(".layui-form").find("tbody tr");
                for(var i=0;i<$tr.length;i++){
                    data[i].trOther8 = $($tr).eq(i).find('td[data-field="type"] dl dd.layui-this').attr("lay-value");
                    if($($tr).eq(i).find('td[data-field="type"] dl dd.layui-this').attr("lay-value") == "通过"){
                        data[i].trStatus = "2";
                    }else if($($tr).eq(i).find('td[data-field="type"] dl dd.layui-this').attr("lay-value") == "未通过"){
                        data[i].trStatus = "3";
                    }
                }
            }
            if(num == "5"){
                var data = table.cache["task"];
                var $tr = $("#task").next(".layui-form").find("tbody tr");
                for(var i=0;i<$tr.length;i++){
                    data[i].trOther8 = $($tr).eq(i).find('td[data-field="type"] dl dd.layui-this').attr("lay-value");
                    if($($tr).eq(i).find('td[data-field="type"] dl dd.layui-this').attr("lay-value") == "通过"){
                        data[i].trStatus = "2";
                    }else if($($tr).eq(i).find('td[data-field="type"] dl dd.layui-this').attr("lay-value") == "未通过"){
                        data[i].trStatus = "3";
                    }
                }
                for(var i=0;i<$tr.length;i++){
                    data[i].trOther9 = $($tr).eq(i).find('td[data-field="trOther9"] dl dd.layui-this').attr("lay-value");
                }
                for(var i=0;i<$tr.length;i++){
                    data[i].trOther10 = $($tr).eq(i).find('td[data-field="trOther10"] dl dd.layui-this').attr("lay-value");
                }
                for(var i=0;i<$tr.length;i++){
                    data[i].trOther11 = $($tr).eq(i).find('td[data-field="trOther11"] dl dd.layui-this').attr("lay-value");
                }
            }
            if(num == "6"){
                var data = table.cache["expect"];
                var $tr = $("#expect").next(".layui-form").find("tbody tr");
                for(var i=0;i<$tr.length;i++){
                    data[i].trOther8 = $($tr).eq(i).find('td[data-field="type"] dl dd.layui-this').attr("lay-value");
                    if($($tr).eq(i).find('td[data-field="type"] dl dd.layui-this').attr("lay-value") == "通过"){
                        data[i].trStatus = "2";
                    }else if($($tr).eq(i).find('td[data-field="type"] dl dd.layui-this').attr("lay-value") == "未通过"){
                        data[i].trStatus = "3";
                    }
                }
                for(var i=0;i<$tr.length;i++){
                    data[i].trOther7 = $($tr).eq(i).find('td[data-field="trOther7"] dl dd.layui-this').attr("lay-value");
                }
                for(var i=0;i<$tr.length;i++){
                    data[i].trOther9 = $($tr).eq(i).find('td[data-field="trOther9"] dl dd.layui-this').attr("lay-value");
                }
                for(var i=0;i<$tr.length;i++){
                    data[i].trOther10 = $($tr).eq(i).find('td[data-field="trOther10"] dl dd.layui-this').attr("lay-value");

                }
            }
            if(data.length == 0){
                layui.layer.msg("无数据不可保存");
                return false;
            }else{
                $.ajax({
                    type: "post",
                    url: "/ResultManagement/examinationList",
                    dataType: "json",
                    data: JSON.stringify(data),
                    contentType: "application/json;charset=UTF-8",
                    success: function (res) {
                        if (res.flag) {
                            layer.msg("保存成功");
                        } else {
                            layer.msg(res.msg);
                        }
                    }
                })
            }

        });
    });
    // 表格内附件查阅及下载操作
    // 鼠标移入
    function shover(e) {
        e.find(".operationDiv").css("display","block");
        e.find("span.spanNa").html(e.find(".giv").html());
    }
    // 鼠标移出
    function sover(e) {
        e.find(".operationDiv").css("display","none");
    }
    // 下载
    function down(e) {
        var attachid = e.parents(".operationDiv").prev("span.giv").attr("attachid");
        if(attachid == undefined || attachid=='' || attachid == "undefined"){
            layer.msg("文件损坏或未上传附件")
        }else{
            window.location.href = "/equipment/limsDownload?model=resultsManagement&attachId=" +attachid
        }
    }
    // 查阅
    function look(e){
        var attachid = e.parents(".operationDiv").prev("span.giv").attr("attachid");
        if(attachid == undefined || attachid=='' || attachid == "undefined"){
            layer.msg("文件损坏或未上传附件")
        }else{
            selectFile1(attachid,"resultsManagement");
        }

    }
    //查看附件
    function selectFile1(attchId,model) {
        if(attchId){
            //查看附件
            var data={
                attachId:attchId,
                model:model
            }
            var res=toAjaxT1("/equipment/selectAttchUrl",data);
            if(res.code==0){
                if(res.object){
                    limsPreview1(res.object);
                }
            }
        }

    }
    //附件预览点击调取
    function limsPreview1(attrUrl) {
        var url = '';
        if(attrUrl != undefined&&attrUrl.indexOf('&ATTACHMENT_NAME=') > -1){
            var atturl1 = attrUrl.split('&ATTACHMENT_NAME=')[0] + '&ATTACHMENT_NAME=';
            var atturl2 = '';
            if(attrUrl.split('&ATTACHMENT_NAME=')[1] != undefined&&attrUrl.split('&ATTACHMENT_NAME=')[1].indexOf('&') > -1){
                for(var i=1;i<attrUrl.split('&ATTACHMENT_NAME=')[1].split('&').length;i++){
                    atturl2 += '&' + attrUrl.split('&ATTACHMENT_NAME=')[1].split('&')[i];
                }
                url = atturl1 + atturl2;
            }else{
                url = atturl1;
            }
        }
        if(limsUrlGetRequest('?'+attrUrl) == 'pdf' || limsUrlGetRequest('?'+attrUrl) == 'PDF'){
            layui.layer.open({
                type: 2,
                title: '预览',
                offset:["20px",""],
                content: "/pdfPreview?"+url,
                area: ['80%', '80%']
            })
            // $.popWindow("/pdfPreview?"+url,PreviewPage,'0','0','1200px','600px');
        }else if(limsUrlGetRequest('?'+attrUrl) == 'png' || limsUrlGetRequest('?'+attrUrl) == 'PNG'|| limsUrlGetRequest('?'+attrUrl) == 'jpg' || limsUrlGetRequest('?'+attrUrl) == 'JPG'|| limsUrlGetRequest('?'+attrUrl) == 'txt'|| limsUrlGetRequest('?'+attrUrl) == 'TXT'){
            layui.layer.open({
                type: 2,
                title: '预览',
                content: "/xs?"+url,
                offset:["20px",""],
                area: ['80%', '80%'],
                success:function(layero, index){
                    var iframeWindow = window['layui-layer-iframe'+ index];
                    var doc = $(iframeWindow.document);
                    doc.find('img').css("width","100%");
                }
            })
            // $.popWindow("/xs?"+url,PreviewPage,'0','0','1200px','600px');
        }else{
            pdurl1(limsUrlGetRequest('?'+attrUrl),attrUrl)
        }
    }
    //同步
    function toAjaxT1(url,data) {
        var result;
        $.ajax({
            url:url,
            data:data,
            type: 'post',
            async:false,
            dataType: 'json',
            success: function (res){
                result=res;
            }
        });
        return result;
    }
    //截取附件文件后缀
    function limsUrlGetRequest(name) {
        var attach=name
        return attach.substring(attach.lastIndexOf(".")+1,attach.length);
    }

    function pdurl1(gs,atturl){ //根据后缀判断选择调取那种打开方式
        if(atturl != undefined&&atturl.indexOf('&ATTACHMENT_NAME=') > -1){
            var atturl1 = atturl.split('&ATTACHMENT_NAME=')[0] + '&ATTACHMENT_NAME=';
            var atturl2 = '';
            if(atturl.split('&ATTACHMENT_NAME=')[1] != undefined&&atturl.split('&ATTACHMENT_NAME=')[1].indexOf('&') > -1){
                for(var i=1;i<atturl.split('&ATTACHMENT_NAME=')[1].split('&').length;i++){
                    atturl2 += '&' + atturl.split('&ATTACHMENT_NAME=')[1].split('&')[i];
                }
                atturl = atturl1 + atturl2;
            }else{
                atturl = atturl1;
            }
        }
        if(gs == 'png'||gs == 'jpg'||gs == 'bmp' || gs == 'emf' || gs == 'gif'|| gs == 'pcx'|| gs == 'pcd'|| gs == 'ai'|| gs == 'webp'|| gs == 'WMF'|| gs == 'dxf' ||gs == 'PNG'||gs == 'JPG'||gs == 'BMP' || gs == 'EMF' || gs == 'GIF'|| gs == 'PCX'|| gs == 'PCD'|| gs == 'AI'|| gs == 'WEBP'|| gs == 'wmf'|| gs == 'DXF'|| gs == 'txt'|| gs == 'TXT'){
            $.popWindow("/xs?"+atturl,PreviewPage,'0','0','1200px','600px');
        }else if(gs == 'mp4'||gs == 'rmvb'||gs == 'avi'||gs == 'ifo'||gs == 'wmv'||gs == 'MP4'||gs == 'RMVB'||gs == 'AVI'||gs == 'IFO'||gs == 'WMV'){
            layer.open({type: 2, title: false, area: ['630px', '360px'], shade: 0.8, closeBtn: 0, shadeClose: true, content: "/common/video?videoatturlsplit="+atturl});
            layer.msg('点击任意处关闭');
        }else if(gs == 'pdf'||gs == 'PDF'){
            $.popWindow("/pdfPreview?"+atturl,PreviewPage,'0','0','1200px','600px');
        }else{
            var url = "/common/webOfficeView?documentEditPriv=0&fomat="+gs+"&"+atturl;
            $.ajax({
                url:'/syspara/selectTheSysPara?paraName=OFFICE_EDIT',
                type:'post',
                datatype:'json',
                async:false,
                success: function (res) {
                    if(res.flag){
                        if(res.object[0].paraValue == 0){
                            //默认加载NTKO插件 进行跳转
                            url = "/common/ntkoview?documentEditPriv=0&fomat="+gs+"&"+atturl;
                        }
                    }

                }
            })
            setTimeout(function(){
                $.popWindow(url,PreviewPage,'0','0','1200px','600px');
            }, 1000);
        }
    }
</script>

